﻿using Asterisk.NET.FastAGI;
using Asterisk.NET.FastAGI.MappingStrategies;
using System;
using System.Collections.Generic;

namespace $safeprojectname$
{
    class Program
    {

        /*
         * AsterNET FastAGI Template
         * 
         * PLEASE NOTE: If this template fails to compile because AsterNET is missing
         * bring up the Package Manager Console (nuget) and type:
         *  
         *  install-package asternet -pre
         *  
         * Because as of 29/10/2013 - AsterNET is still in pre-release on Nuget.
         * 
         * Asterisk
         * To use this template you'll need to configure your Asterisk Installation
         * to point to your new AGI Script. For example:
         * (in extensions.conf)
         * ----------------------------
         * exten => <exten_number>,1,agi("agi://<your_ip>/FastAGIScript1")
         * ----------------------------
         * For more help using the extensions.conf, visit:
         * http://www.voip-info.org/wiki/view/Asterisk+config+extensions.conf
         * or
         * http://www.voip-info.org/wiki/view/Asterisk+FastAGI
         * 
         * FastAGI
         * Your first AGI script is located in the AGIScripts folder, file FastAGIScript1.cs
         * 
         * For information on using this template and asternet, visit: 
         * https://astertemplates.codeplex.com/documentation
         * 
         */
        static void Main(string[] args)
        {

            AsteriskFastAGI agi = new AsteriskFastAGI();

            agi.MappingStrategy = new GeneralMappingStrategy(
                /*
                * You can add additional scripts here. Each script has it's own class, 
                * and needs to be configured in the extension.conf in asterisk
                */
                new List<ScriptMapping>()
                {
                    new ScriptMapping() {
                        ScriptName = "FastAGIScript1",
                        ScriptClass = "$safeprojectname$.AGIScripts.FastAGIScript1"
                    }
                });

            Console.WriteLine(string.Format("Running FastAGI Server. Press ctrl-c to stop..."));
            agi.Start();

        }
    }
}
